package com.example.mytext;

import androidx.appcompat.app.AppCompatActivity;

import android.app.Activity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.ydl.slideviewpager.SlideViewPager;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends Activity {

    private SlideViewPager viewPager;

    private MyAdapter adapter;
    private List<View> list=new ArrayList<>();
    private List<String> stringList=new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
    }


    private void initView(){
        viewPager=findViewById(R.id.visible);

        addView();
        addView();
        addView();

        adapter=new MyAdapter(list);
        viewPager.setTextView(stringList);
        viewPager.setAdapter(adapter);

//        viewPager.setCurrentItem(8);
        viewPager.show();
//        viewPager.setSize(14);
//        viewPager.setLineHeight(80);
//        viewPager.setColor("#0000ff");
//        viewPager.setLineResource(R.mipmap.ic_launcher);
//        viewPager.setLineColor("#00FF00");

    }

    private void addView(){

        TextView textView=new TextView(this);
        textView.setText("第"+list.size()+"页");
        textView.setTextSize(60);
        textView.setGravity(Gravity.CENTER);
        list.add(textView);

        stringList.add("第"+stringList.size()+"页");
    }
}